
#ifndef   __EXTERNAL_EEPROM_24FC512
#define   __EXTERNAL_EEPROM_24FC512

#define   ACK_OK		0
#define   ACK_FAIL	1

#define   I2_DELAY()	NOP();NOP();NOP();NOP();

#define   I2C_GET_ACK()	PIN_SCL=0;PIN_SDA_DIR=PIN_INPUT;PIN_SCL=1;NOP();NOP();NOP();NOP();	


#define   I2C_ERROR	(-1)

#define   PIN_SDA			PORT_0_PIN.PIN_27
#define   PIN_SDA_DIR	PORT_0_DIR.PIN_27

#define   PIN_SCL			PORT_0_PIN.PIN_28
#define   PIN_SCL_DIR	PORT_0_DIR.PIN_28

void Ex_EEPROM_Init( void );


int Ex_StrCmp( register const unsigned char* Reference, unsigned int Address  );

int Ex_ReadByte ( unsigned int Address ); /* if returned (-1) - ERROR */
unsigned char Ex_WriteByte( unsigned int Address, unsigned char Byte );

unsigned char Ex_Str_SaveTo( unsigned int Address, unsigned char* Buffer );

unsigned char Ex_Str_LoadFrom( unsigned char* Buffer, unsigned int Address );
unsigned char Ex_LoadFrom__( unsigned char* Buffer, unsigned int Address, unsigned char ByteCount );

//unsigned char Ex_SaveTo( unsigned int Address, unsigned char* Buffer, unsigned int ByteCount );
//int Ex_LoadFrom( unsigned int Address, void* Buffer, unsigned int ByteCount );



int Ex_WriteData( unsigned int Address, void* Buffer, unsigned int ByteCount );
int Ex_ReadData( unsigned int Address, void* Buffer, unsigned int ByteCount );
int Ex_CheckRecord( unsigned int RecordAddress, void* Reference, unsigned int ByteCount );



unsigned char Ex_SaveAndCheck( unsigned int Address, unsigned char* Buffer, unsigned char ByteCount );
unsigned char Ex_ClearAll( void );
unsigned char i2c_Seq_Read_Test( void );

unsigned char Ex_Load_And_Send( unsigned int Address, unsigned int ByteCount, unsigned char CheckSum );
	
unsigned char Ex_LoadFrom__ForTest( unsigned int Address, unsigned int ByteCount );
unsigned char Ex_SaveTo_ForTest( unsigned int Address, unsigned int ByteCount );
unsigned char Ex_Load( unsigned char* Buffer, unsigned int Address );

int Ex_MemSet( unsigned int Address, unsigned char Fill, unsigned int ByteCount );

/*  */
unsigned char i_Ex_SaveTo( unsigned int Address, unsigned char* Buffer, unsigned char ByteCount );
/*  */

void Ex_Test ( void );

#endif
	
